package com.richapp.launcher.serialport.infrared.abstracts;

import com.richapp.launcher.serialport.infrared.interfaces.IMessage;
import com.richapp.launcher.serialport.infrared.interfaces.InfraredMessageListener;

import java.io.DataInputStream;
import java.io.DataOutputStream;

/**
 * Created by jack on 2015/4/3 0003.
 */
public abstract class AMessage implements IMessage {

    /**
     * 指令控制类型,一个字节
     * 0x01 红外发射
     * 0x02 指令学习
     */
    private byte type = 0x01;

    /**
     * 数据长度,2个字节
     */
    private byte[] length = null;

    /**
     * 指令数据
     */
    private byte[] sendData =  null;

    /**
     * 校验,一个字节,= 指令+ 数据长度 + 数据累加和
     */
    private byte check = 0x00;

    /**
     * 要发送的所有数据
     */
    private byte[] allData = null;

    private InfraredMessageListener infraredMessageListener = null;

    private DataInputStream dataInputStream;
    private DataOutputStream dataOutputStream;

    private long startTime = 0;
    private long stopTime = 0;

    public AMessage(){

    }

    public byte[] getLength() {
        return length;
    }

    public void setLength(byte[] length) {
        this.length = length;
    }

    public byte getType() {
        return type;
    }

    public void setType(byte type) {
        this.type = type;
    }

    public byte getCheck() {
        return check;
    }

    public void setCheck(byte check) {
        this.check = check;
    }

    public byte[] getSendData() {
        return sendData;
    }

    public void setSendData(byte[] sendData) {
        this.sendData = sendData;
    }

    public byte[] getAllData() {
        return allData;
    }

    public void setAllData(byte[] allData) {
        this.allData = allData;
    }

    public DataInputStream getDataInputStream() {
        return dataInputStream;
    }

    public void setDataInputStream(DataInputStream dataInputStream) {
        this.dataInputStream = dataInputStream;
    }

    public DataOutputStream getDataOutputStream() {
        return dataOutputStream;
    }

    public void setDataOutputStream(DataOutputStream dataOutputStream) {
        this.dataOutputStream = dataOutputStream;
    }

    public long getStartTime() {
        return startTime;
    }

    public void setStartTime(long startTime) {
        this.startTime = startTime;
    }

    public long getStopTime() {
        return stopTime;
    }

    public void setStopTime(long stopTime) {
        this.stopTime = stopTime;
    }

    public InfraredMessageListener getInfraredMessageListener() {
        return infraredMessageListener;
    }

    public void setInfraredMessageListener(InfraredMessageListener infraredMessageListener) {
        this.infraredMessageListener = infraredMessageListener;
    }
}
